<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	</body>
	<script>
		/*将字符类型时间转换为yyyy-MM-dd格式*/
		function formatDate(oldDate) {
			let dateArr = oldDate.split("-");
			dateArr["1"] = dateArr["1"].length == 1 ? "0" + dateArr["1"] : dateArr["1"];
			dateArr["2"] = dateArr["2"].length == 1 ? "0" + dateArr["2"] : dateArr["2"];
			return dateArr.join("-");
		}

		function setItemDay(currentDay) {
			let d = new Date(currentDay);
			d = +d + 1000 * 60 * 60 * 24;
			d = new Date(d);
			return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
		}

		function getRangeDay(startDate, endData) {
			let dateList = [startDate];
			let dayCount = (new Date(endData) - new Date(startDate)) / (1000 * 60 * 60 * 24);
			for (let i = 0; i < dayCount; i++) {
				let currentDay = setItemDay(dateList[i]);
				currentDay = formatDate(currentDay);
				dateList.push(currentDay);
			}
			console.log(dateList)
			return dateList;
		}

		getRangeDay('2022-8-10', '2022-8-16')
	</script>
</html>
